package com.texaco.chapasFutbol.utilidades;

public class Colores {

	/**
	 * Converts a supplied HEX Color Code to OpenGL RGB Double Color string<br>
	 * 
	 * <b>Example :</b> ColorBackground(HexToOpenGL("#549d3a"));<br>
	 * <b>Output :</b> ColorBackground(0.3294117647058824f, 0.6156862745098039f, 
	 *                 0.2274509803921569f);<br>
	 * @param hexcolor - Hex Color Code to convert (i.e. #549d3a or 549d3a)
	 * @return doubleGLColor - Returns a string with RGB converted OpenGL double 
	 *                        color values
	 */
	public static double[] hexToOpenGL(String hexcolor)
	{
	        double[] GLVal = new double[3];
	       
	        if(hexcolor.length()>6)
	                hexcolor = hexcolor.substring(1,7);
	       
	        GLVal[0] = Integer.parseInt(hexcolor.substring(0,2),16) / 255.0;
	        GLVal[1] = Integer.parseInt(hexcolor.substring(2,4),16) / 255.0;
	        GLVal[2] = Integer.parseInt(hexcolor.substring(4,6),16) / 255.0;
	        double[] doubleGLColor = {(GLVal[0]) , (GLVal[1]) , (GLVal[2])} ;
	 
	        return doubleGLColor;
	}
}
